<!--
 * @Author: zengwj
 * @Date: 2022-07-20 14:27:57
 * @LastEditors: zengwj
 * @LastEditTime: 2022-07-20 14:27:58
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function createArray(...elements) {
      let handler = {
        get(target, propKey, receiver) {
          let index = Number(propKey);
          if (index < 0) {
            propKey = String(target.length + index);
          }
          return Reflect.get(target, propKey, receiver);
        }
      };

      let target = [];
      target.push(...elements);
      return new Proxy(target, handler);
    }

    let arr = createArray('a', 'b', 'c');
    debugger
    arr[-1] // c
  </script>
</body>

</html>